using System;
using System.Collections.Generic;
using UnityEngine;

[Serializable]
public class raw_class
{
	public bool foldout;

	public bool settings_foldout;

	public int raw_number;

	public List<int> file_index;

	public List<bool> file_foldout;

	public string path;

	public bool tile_offset;

	public bool flip_x;

	public bool flip_y;

	public bool flipTotalY;

	public bool flipTotalX;

	public bool clamp;

	public int list_length;

	public int list_row;

	public bool display_short_list;

	public list_condition_enum raw_list_mode;

	public image_mode_enum raw_mode;

	public object @object;

	public auto_search_class auto_search;

	public bool raw_auto_scale;

	public Vector2 conversion_step;

	public float tile_x;

	public float tile_y;

	public bool tile_link;

	public float tile_offset_x;

	public float tile_offset_y;

	public bool rgb;

	public bool rotation;

	public float rotation_value;

	public bool output;

	public float output_pos;

	public raw_class()
	{
		foldout = true;
		file_index = new List<int>();
		file_foldout = new List<bool>();
		path = string.Empty;
		list_length = 1;
		list_row = 4;
		auto_search = new auto_search_class();
		raw_auto_scale = true;
		conversion_step = new Vector2(1f, 1f);
		tile_x = 1f;
		tile_y = 1f;
		rgb = true;
		file_index.Add(-1);
		file_foldout.Add(item: true);
	}

	public void adjust_list()
	{
		int num = list_length - file_index.Count;
		int num2 = default(int);
		if (num > 0)
		{
			for (num2 = 0; num2 < num; num2++)
			{
				file_index.Add(-1);
				file_foldout.Add(item: false);
			}
		}
		if (num < 0)
		{
			num *= -1;
			for (num2 = 0; num2 < num; num2++)
			{
				file_index.RemoveAt(file_index.Count - 1);
				file_foldout.RemoveAt(file_foldout.Count - 1);
			}
		}
	}

	public void set_raw_auto_scale(terrain_class preterrain1, Rect area, List<raw_file_class> raw_files, int raw_number)
	{
		if (raw_number >= file_index.Count || !raw_files[file_index[raw_number]].assigned || preterrain1 == null)
		{
			return;
		}
		if (raw_mode == image_mode_enum.Area)
		{
			conversion_step.x = area.width / (raw_files[file_index[raw_number]].resolution.x - 1f);
			conversion_step.y = area.height / (raw_files[file_index[raw_number]].resolution.y - 1f);
		}
		else if (raw_mode == image_mode_enum.Terrain)
		{
			if ((bool)preterrain1.terrain)
			{
				ref Vector2 reference = ref conversion_step;
				Vector3 size = preterrain1.terrain.terrainData.size;
				reference.x = size.x / (raw_files[file_index[raw_number]].resolution.x - 1f);
				ref Vector2 reference2 = ref conversion_step;
				Vector3 size2 = preterrain1.terrain.terrainData.size;
				reference2.y = size2.z / (raw_files[file_index[raw_number]].resolution.y - 1f);
			}
		}
		else if (raw_mode == image_mode_enum.MultiTerrain)
		{
			ref Vector2 reference3 = ref conversion_step;
			Vector3 size3 = preterrain1.terrain.terrainData.size;
			reference3.x = size3.x * preterrain1.tiles.x / (raw_files[file_index[raw_number]].resolution.x - 1f);
			ref Vector2 reference4 = ref conversion_step;
			Vector3 size4 = preterrain1.terrain.terrainData.size;
			reference4.y = size4.z * preterrain1.tiles.y / (raw_files[file_index[raw_number]].resolution.y - 1f);
		}
	}
}
